<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<#include "/common/resources.ftl"/>
<script type="text/javascript">
	function m_submit(){
		if($('#saveOrEditForm').form('validate')){
			$.ajax({
		        type: "POST",
		        url:'${ctx}/qfbao/partnerinfo/save_edit',
		        dataType:'JSON',
		        data:$('#saveOrEditForm').serialize(),// 你的formid
		        error: function(request) {
		            $.messager.alert("错误信息","服务器繁忙");
		        },
		        success: function(rs) {
		        	if(rs.isSuccess=="0"){
		        	    window.location.href = 'manage';
		        	}else{
		        	    $.messager.alert("错误信息",rs.errorMsg);
		        	}
		        }
		    });
		}
	}
	
	function m_back(){
		window.location.href = 'manage';
	}
	
	
	
	 //自定义验证
  	$.extend($.fn.validatebox.defaults.rules, {phoneRex: {
		validator: function(value){
	    	var rex=/^((13[0-9])|(15[^4,\D])|(18[0,2,5-9]))\d{8}$/;
	    	//var rex=/^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/;
		    //区号：前面一个0，后面跟2-3位数字 ： 0\d{2,3}
		    //电话号码：7-8位数字： \d{7,8
		    //分机号：一般都是3位数字： \d{3,}
		     //这样连接起来就是验证电话的正则表达式了：/^((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/		 
		    //var rex2=/^((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/;
		    //if(rex.test(value)||rex2.test(value))
		    if(rex.test(value)){
				return true;
		    }else{
				return false;
		    }
	    },
    	message: '请输入正确的手机格式'
	},
	pwdReg:{
		validator: function(value){
			var reg = /^[a-zA-Z0-9~!@#$%^&*()-_+=`{}\[\]:;"'<>?,.\/\\]{8,20}$/;
			 if(reg.test(value)){
				return true;
		    }else{
				return false;
		    }
		},
		message: '密码为长度8-20位字符'
	}
});
	function initShowDiv(isView){
		  if(isView==1){
		     //编辑模式
		      $("#detailViewDiv").hide();
		      $("#detailEditorDiv").show();
		  }else if(isView==0) {
		     //查看模式
		     $("#detailEditorDiv").hide();
		     $("#detailViewDiv").show();
		  }else if(isView==2){
		      //新增模式
		      $("#detailViewDiv").hide();
		      $("#detailEditorDiv").show();
		      $("#cancelBtn").hide();
		  }
	}
	
	$(function(){
	    //初始化页面显示div
	    var isView="${isView}";
	    initShowDiv(isView);
	    var companyType ="${company.companyType}";
	    if(companyType&&1==companyType){
	    	$("#edit").hide();
	    }
	});
</script>
</head>
<body>
  <div id="detailViewDiv" style="display:none">
  	  <div class="ipt_line_long" style="width:100%; height:50px; overflow:hidden; margin-top:20px;  ">
	  			 <button class="red_100" onclick="javascript:m_back();return false;" style="background-color:#74D86A;float:right">返回</button>
	             <button id="edit"class="red_100" onclick="javascript:initShowDiv(1);" style="float:right">编辑</button>      
	  </div>
  <div class="fm_sty" style="margin: 20px 0px 0px;">
        <div class="ipt_line">
				<span class="ipt_title">姓名</span>
				${model.accountName}
		</div>
	       	
       	<div class="ipt_line">
			   <span class="ipt_title">手机</span>
			   ${model.phone}
		</div>
		

	    
	    <div class="ipt_line">
			  <span class="ipt_title">状态</span>
			  ${model.statusCN}
		</div>

       	<div class="ipt_line">
			  <span class="ipt_title">账户类型</span>
			  ${model.accountTypeCN}
		</div>

       <div class="ipt_line">
				<span class="ipt_title">所属公司</span>
				${company.companyName}
	    </div>

	</div>
  </div>
  
  
  
 <div style="display:none" id="detailEditorDiv">
 <div class="ipt_line_long" style="width:100%; height:50px; overflow:hidden; margin-top:20px;  ">
  			 <button class="red_100" onclick="javascript:m_back();return false;" style="background-color:#74D86A;float:right">返回</button>
  			 <button class="red_100" onclick="javascript:initShowDiv(0);" style="float:right" id="cancelBtn">取消</button>
             <button class="red_100" onclick="javascript:m_submit();return false;" style="float:right">保存</button> 
  </div>
  <form id="saveOrEditForm" class="loan_list_form" name="saveOrEditForm">
  <input type="hidden" name="id" value="${model.id}" />
  <div class="fm_sty" style="margin: 20px 0px 0px;">
		<div class="ipt_line">
			<span class="ipt_title">姓名</span>
			<input type="text" name="accountName" value="${model.accountName}" class="easyui-validatebox" style="height:39px;width:266px;" required="true"/>
		</div>
		<div class="ipt_line">
			<span class="ipt_title">手机</span>
			<input type="text" required="true" name="phone" value="${model.phone}" class="easyui-numberbox" style="height:39px;width:266px;" data-options="validType:'phoneRex'"/>
			<input type="hidden"  name="prePhone" value="${model.phone}" />
			<input type="hidden"  name="isView" value="${isView}" />
		</div>
		<#if model.id?exists >
        <#else>
        	<div class="ipt_line">
				<span class="ipt_title">密码</span>
				<input type="password" required="true" name="password" value="${model.password}" class="easyui-validatebox" style="height:39px;width:266px;" required="true" missingMessage="请填写密码！"data-options="validType:'pwdReg'"/>
			</div>
			<div class="ipt_line">
				<span class="ipt_title">确认密码</span>
				<input type="password" required="true" name="truePassWord" value="${model.password}" class="easyui-validatebox" style="height:39px;width:266px;" required="true" missingMessage="请填写确认密码！"data-options="validType:'pwdReg'"/>
			</div>
        </#if>
		<#if isView=="2">
		  	<div class="ipt_line">
				<span class="ipt_title">所属公司</span>
				<input id="higherid_id" name="higherid"  value="${model.higherid}" class="easyui-combobox" style="height:39px; width:263px;"
				required="true" missingMessage="所属公司不能为空！"
					data-options="
						valueField:'id',
						textField:'companyName',
						url:'${ctx}/jr/company/getList'" />
			</div>
		<#else>
		    <div class="ipt_line">
				<span class="ipt_title">所属公司</span>
				<input  id="higherid_id"  name="higherid" value="${model.higherid}" class="easyui-combobox" style="height:39px; width:263px;"
				required="true" missingMessage="开户行不能为空！"
					data-options="
						valueField:'id',
						textField:'companyName',
						url:'${ctx}/jr/company/getList'" />
				<input type="hidden" name="preHigherId" value="${model.higherid}"/>
			</div>
		</#if>
			<div class="ipt_line">
			<span class="ipt_title">账户类型</span>
			<#--<input type="text"name="accountType2"readonly value="管理员"  style="height:39px;width:266px;"/>-->
                <!--	<input type="hidden" name="accountType" value="0"  style="height:39px;width:266px;"/>-->
		<input id="accountType" name="accountType" editable="false" value="0" class="easyui-combobox" style="height:39px; width:263px;"
			required="true" missingMessage="账户类型不能为空！"
				data-options="
					valueField:'dicType',
					textField:'dicValue',
					url:'${ctx}/qfbao/partnerinfo/getTypeList'" />
		</div>
	</div>
	</form>
	</div>
</body>
</html>
